﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ERP_CargoRelation.aspx.cs" Inherits="CRM_Manager_ERP_CargoRelation" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>客户商品目录关系</title>
    <link href="../css/PageStyle.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript" src="../JavaScript/Common.js"></script>

    <script type="text/javascript">
        function SelectedCargo() {
            var record1 = gridCargo.selModel.getSelected();
            if (record1 == null)
            {
                return;
            }
            var record2 = gridCusCargo.selModel.getSelected();
            if (record2 == null) {
                return;
            }
            Ext.net.DirectMethods.LoadRelation(record1.data.CargoId, record2.data.CargoId, record2.data.CustomId);
        }
        function ReLoad()
        {
            gridCusCargo.reload();
        }
        function SelectedCusCargo() {
            var record1 = gridCargo.selModel.getSelected();
            if (record1 == null) {
                return;
            }
            var record2 = gridCusCargo.selModel.getSelected();
            if (record2 == null) {
                return;
            }
            Ext.net.DirectMethods.LoadRelation(record1.data.CargoId, record2.data.CargoId, record2.data.CustomId);
        }
        function ExtBtn_MappingDept_Click() {
            if (!gridCargo.hasSelection()) {
                Ext.Msg.alert('系统提示', '请选择商品信息');
                return;
            }
            if (!gridCusCargo.hasSelection()) {
                Ext.Msg.alert('系统提示', '请选择要对照的客户商品信息');
                return;
            }
            var record1 = gridCargo.selModel.getSelected();
            var record2 = gridCusCargo.selModel.getSelected();
            Ext.net.DirectMethods.MappingMat(record1.data.CargoId, record1.data.DetailId, record2.data.CargoId, record2.data.DetailId, record2.data.CustomId);
        }
        function GetStateName(value) {
            switch (value) {
                case 0:
                    return "无效";
                case 1:
                    return "有效";
                default:
                    return value;
            }
        }
        //var triggerHandler = function(el, trigger, index) {
        //    GridPanel1.reload();
        //}
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <ext:ResourceManager ID="ResourceManager1" runat="server" AjaxViewStateMode="Enabled" />
    <ext:Viewport ID="Viewport1" runat="server" Layout="FitLayout">
        <Content>
            <ext:BorderLayout ID="BorderLayout1" runat="server">
                <Center>
                    <ext:Panel ID="Panel1" runat="server" BodyBorder="false">
                        <Content>
                            <ext:RowLayout ID="RowLayout1" runat="server">
                                <Rows>
                                    <ext:LayoutRow RowHeight="0.7">
                                        <ext:Panel ID="Panel4" runat="server" Border="false" Layout="Fit">
                                            <Content>
                                                <ext:Container ID="Container4" runat="server" Layout="Column">
                                                    <Items>
                                                        <ext:Container ID="Container5" runat="server" LabelAlign="Right" Layout="FitLayout"
                                                            ColumnWidth=".5">
                                                            <Items>
                                                                <ext:Panel ID="Panel5" runat="server" Border="true" Layout="FitLayout" Cls="tool-form" >
                                                                    <TopBar>
                                                                        <ext:Toolbar ID="Toolbar3" runat="server">
                                                                            <Items>
                                                                                <ext:Label ID="Label2" Text="商品列表" runat="server">
                                                                                </ext:Label>
                                                                                <ext:ToolbarFill ID="ToolbarFill2" runat="server">
                                                                                </ext:ToolbarFill>
                                                                                <ext:TextField runat="server" ID="exttxtf_Query" TabTip="code">
                                                                                    <Listeners>
                                                                                        <KeyDown Handler="Ext.net.DirectMethods.TextKeyPress();">
                                                                                        </KeyDown>
                                                                                    </Listeners>
                                                                                </ext:TextField>
                                                                            </Items>
                                                                        </ext:Toolbar>
                                                                    </TopBar>
                                                                    <Content>
                                                                        <ext:GridPanel ID="gridCargo" runat="server" AutoScroll="true" TrackMouseOver="true"
                                                                            StripeRows="true" Border="false">
                                                                            <ColumnModel ID="ColumnModel1" runat="server">
                                                                                <Columns>
                                                                                    <ext:Column Header="<center>编号</center>"  DataIndex="DetailId" />
                                                                                    <ext:Column Header="<center>商品名称</center>"  DataIndex="CargoName" />
                                                                                    <ext:Column Header="<center>规格</center>" DataIndex="Spec" />
                                                                                    <ext:Column Header="<center>型号</center>" DataIndex="Version" />
                                                                                    <ext:Column Header="<center>产地</center>" DataIndex="Area" Align="Right">
                                                                                    </ext:Column>
                                                                                    <ext:Column Header="<center>生产厂家</center>" DataIndex="ProduceName" />
                                                                                    <ext:Column Header="<center>价格</center>" DataIndex="Supplyprice">
                                                                                    </ext:Column>
                                                                                </Columns>
                                                                            </ColumnModel>
                                                                            <Listeners>
                                                                                <RowClick Fn="SelectedCargo" />
                                                                            </Listeners>
                                                                            <Store>
                                                                                <ext:Store ID="storeCargo" runat="server" AutoLoad="true"  OnRefreshData="MyData_Refresh">
                                                                                    <Proxy>
                                                                                        <ext:PageProxy>
                                                                                        </ext:PageProxy>
                                                                                    </Proxy>
                                                                                    <Reader>
                                                                                        <ext:JsonReader IDProperty="DetailId">
                                                                                            <Fields>
                                                                                                <ext:RecordField Name="DetailId" />
                                                                                                <ext:RecordField Name="CargoName" />
                                                                                                <ext:RecordField Name="Spec" />
                                                                                                <ext:RecordField Name="Version" />
                                                                                                <ext:RecordField Name="Area" />
                                                                                                <ext:RecordField Name="ProduceName" />
                                                                                                <ext:RecordField Name="Supplyprice" />
                                                                                                <ext:RecordField Name="CargoId" />
                                                                                            </Fields>
                                                                                        </ext:JsonReader>
                                                                                    </Reader>
                                                                                </ext:Store>
                                                                            </Store>
                                                                            <SelectionModel>
                                                                                <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true">
                                                                                </ext:RowSelectionModel>
                                                                            </SelectionModel>
                                                                        </ext:GridPanel>
                                                                    </Content>
                                                                </ext:Panel>
                                                            </Items>
                                                        </ext:Container>
                                                        <ext:Container ID="Container6" runat="server" Width="50" Layout="FitLayout">
                                                            <Items>
                                                                <ext:Panel ID="Panel6" runat="server" Border="false" Layout="FitLayout">
                                                                    <Content>
                                                                        <ext:RowLayout ID="RowLayout2" runat="server">
                                                                            <Rows>
                                                                                <ext:LayoutRow RowHeight=".5">
                                                                                    <ext:Panel ID="Panel7" runat="server" Border="false">
                                                                                        <Content>
                                                                                        </Content>
                                                                                    </ext:Panel>
                                                                                </ext:LayoutRow>
                                                                                <ext:LayoutRow>
                                                                                    <ext:Panel ID="Panel8" runat="server" Border="false" Height="40" StyleSpec=" text-align:center">
                                                                                        <Content>
                                                                                            <ext:Button ID="extbtn_Add" runat="server"  Width="40" Text="对照">
                                                                                                <Listeners>
                                                                                                    <Click Handler="ExtBtn_MappingDept_Click()" />
                                                                                                </Listeners>
                                                                                            </ext:Button>
                                                                                        </Content>
                                                                                    </ext:Panel>
                                                                                </ext:LayoutRow>
                                                                                <ext:LayoutRow RowHeight=".5">
                                                                                    <ext:Panel ID="Panel10" runat="server" Border="false">
                                                                                        <Content>
                                                                                        </Content>
                                                                                    </ext:Panel>
                                                                                </ext:LayoutRow>
                                                                            </Rows>
                                                                        </ext:RowLayout>
                                                                    </Content>
                                                                </ext:Panel>
                                                            </Items>
                                                        </ext:Container>
                                                        <ext:Container ID="Container7" runat="server" LabelAlign="Right" Layout="FitLayout"
                                                            ColumnWidth=".5">
                                                            <Items>
                                                                <ext:Panel ID="Panel11" runat="server" Border="true" Layout="FitLayout" Cls="tool-form">
                                                                    <TopBar>
                                                                        <ext:Toolbar ID="Toolbar1" runat="server">
                                                                            <Items>
                                                                                <ext:Label ID="Label1" Text="客户商品信息" runat="server">
                                                                                </ext:Label>
                                                                                <ext:ToolbarFill ID="ToolbarFill1" runat="server">
                                                                                </ext:ToolbarFill>
                                                                                <ext:Label ID="Label3" runat="server" Text="客户" />
                                                                                <ext:ComboBox runat="server" ID="combox_CustomId" ValueField="CustomerId" DisplayField="CustomerName">
                                                                                    <Store>
                                                                                        <ext:Store runat="server" ID="store_Custom" AutoLoad="true">
                                                                                            <Reader>
                                                                                                <ext:JsonReader IDProperty="CustomerId">
                                                                                                    <Fields>
                                                                                                        <ext:RecordField Name="CustomerId" />
                                                                                                        <ext:RecordField Name="CustomerName" />
                                                                                                    </Fields>
                                                                                                </ext:JsonReader>
                                                                                            </Reader>
                                                                                        </ext:Store>
                                                                                    </Store>
                                                                                    <Listeners>
                                                                                        <Change Fn="ReLoad" />
                                                                                    </Listeners>
                                                                                </ext:ComboBox>
                                                                                <ext:TextField runat="server" ID="exttxtf_HisCharge">
                                                                                     <Listeners>
                                                                                        <KeyDown Handler="Ext.net.DirectMethods.TextKeyPress1();">
                                                                                        </KeyDown>
                                                                                    </Listeners>
                                                                                </ext:TextField>
                                                                            </Items>
                                                                        </ext:Toolbar>
                                                                    </TopBar>
                                                                    <Content>
                                                                        <ext:GridPanel ID="gridCusCargo" runat="server" AutoScroll="true" TrackMouseOver="true"
                                                                            StripeRows="true" Border="false">
                                                                            <ColumnModel ID="ColumnModel2" runat="server">
                                                                                <Columns>
                                                                                    <ext:Column Header="<center>编号</center>"  DataIndex="DetailId" />
                                                                                    <ext:Column Header="<center>客户名称</center>"  DataIndex="CustomerName" />
                                                                                    <ext:Column Header="<center>商品名称</center>"  DataIndex="CargoName" />
                                                                                    <ext:Column Header="<center>规格</center>" DataIndex="Spec" />
                                                                                    <ext:Column Header="<center>型号</center>" DataIndex="Version" />
                                                                                    <ext:Column Header="<center>产地</center>" DataIndex="Area" Align="Right">
                                                                                    </ext:Column>
                                                                                    <ext:Column Header="<center>生产厂家</center>" DataIndex="ProduceName" />
                                                                                    <ext:Column Header="<center>价格</center>" DataIndex="Supplyprice">
                                                                                    </ext:Column>
                                                                                </Columns>
                                                                            </ColumnModel>
                                                                            <Listeners>
                                                                                <RowClick Fn="SelectedCusCargo" />
                                                                            </Listeners>
                                                                            <Store>
                                                                                <ext:Store ID="storeCusCargo" runat="server" AutoLoad="true" OnRefreshData="MyData_Refresh2" >
                                                                                    <Proxy>
                                                                                        <ext:PageProxy>
                                                                                        </ext:PageProxy>
                                                                                    </Proxy>
                                                                                    <Reader>
                                                                                        <ext:JsonReader IDProperty="DetailId">
                                                                                            <Fields>
                                                                                                <ext:RecordField Name="DetailId" />
                                                                                                <ext:RecordField Name="CustomId" />
                                                                                                <ext:RecordField Name="CustomerName" />
                                                                                                <ext:RecordField Name="CargoName" />
                                                                                                <ext:RecordField Name="Spec" />
                                                                                                <ext:RecordField Name="Version" />
                                                                                                <ext:RecordField Name="Area" />
                                                                                                <ext:RecordField Name="ProduceName" />
                                                                                                <ext:RecordField Name="Supplyprice" />
                                                                                                <ext:RecordField Name="CargoId" />
                                                                                            </Fields>
                                                                                        </ext:JsonReader>
                                                                                    </Reader>
                                                                                </ext:Store>
                                                                            </Store>
                                                                            <SelectionModel>
                                                                                <ext:RowSelectionModel ID="RowSelectionModel2" runat="server" SingleSelect="true">
                                                                                </ext:RowSelectionModel>
                                                                            </SelectionModel>
                                                                        </ext:GridPanel>
                                                                    </Content>
                                                                </ext:Panel>
                                                            </Items>
                                                        </ext:Container>
                                                    </Items>
                                                </ext:Container>
                                            </Content>
                                        </ext:Panel>
                                    </ext:LayoutRow>
                                    <ext:LayoutRow RowHeight="0.3">
                                        <ext:Panel ID="Panel2" Title="对照关系列表" runat="server" Border="true" Layout="FitLayout" Cls="tool-form">
                                            <Items>
                                                <ext:GridPanel ID="GridPanel1" runat="server" AutoScroll="true" TrackMouseOver="true"
                                                    StripeRows="true" Border="false">
                                                    <ColumnModel ID="ColumnModel3" runat="server">
                                                        <Columns>
                                                            <ext:Column Header="<center>编号</center>"  DataIndex="Relationid" />
                                                            <ext:Column Header="<center>商品目录ID</center>"  DataIndex="BCargoId" />
                                                            <ext:Column Header="<center>客户商品目录ID</center>"  DataIndex="CargoId" />
                                                            <ext:Column Header="<center>商品价格ID</center>" DataIndex="OwerDetailId" />
                                                            <ext:Column Header="<center>客户商品价格ID</center>" DataIndex="CusDetailId" />
                                                            <ext:Column Header="<center>状态</center>" DataIndex="RState">
                                                                <Renderer Fn="GetStateName" />
                                                            </ext:Column>
                                                        </Columns>
                                                    </ColumnModel>
                                                    <Store>
                                                        <ext:Store ID="StoreRelations" runat="server" AutoLoad="true">
                                                            <Reader>
                                                                <ext:JsonReader IDProperty="Relationid">
                                                                    <Fields>
                                                                        <ext:RecordField Name="Relationid" />
                                                                        <ext:RecordField Name="CargoId" />
                                                                        <ext:RecordField Name="CustomId" />
                                                                        <ext:RecordField Name="BCargoId" />
                                                                        <ext:RecordField Name="OwerDetailId" />
                                                                        <ext:RecordField Name="CusDetailId" />
                                                                        <ext:RecordField Name="RState" />
                                                                    </Fields>
                                                                </ext:JsonReader>
                                                            </Reader>
                                                        </ext:Store>
                                                    </Store>
                                                    <SelectionModel>
                                                        <ext:RowSelectionModel ID="RowSelectionModel3" runat="server" SingleSelect="true">
                                                        </ext:RowSelectionModel>
                                                    </SelectionModel>
                                                </ext:GridPanel>
                                            </Items>
                                        </ext:Panel>
                                    </ext:LayoutRow>
                                </Rows>
                            </ext:RowLayout>
                        </Content>
                    </ext:Panel>
                </Center>
            </ext:BorderLayout>
        </Content>
    </ext:Viewport>
    </form>
</body>
</html>

